package com.lin.controller;

import com.github.pagehelper.PageInfo;
import dto.SysUserDto;
import org.apache.shiro.SecurityUtils;
import util.ResponseVo;

import java.util.HashMap;
import java.util.Map;

public class BaseController {

    protected ResponseVo pageData(PageInfo<?> pageInfo){
        Map<String,Object> map = new HashMap<>();
        map.put("page",pageInfo.getPageNum());
        map.put("pageSize",pageInfo.getPageSize());
        map.put("total",pageInfo.getTotal());
        map.put("data",pageInfo.getList());
        return ResponseVo.ok(map);
    }

    protected SysUserDto getUser() {
        return (SysUserDto) SecurityUtils.getSubject().getPrincipal();

    }

    protected Long getUserId() {
        return getUser().getUserId();
    }
}
